import sys
from distutils.core import setup
from imagegen import ImageGen
from c.base.version import InfoStrings
import glob
    
# additional files
additionalFiles = [
	"data/IM_ToolRun.png",
	"data/IM_ToolStop.png",
	"data/book_open.png",
	"data/brick.png",
	"data/bricks.png",
	"data/car.png",
	"data/cog_edit.png",
	"data/cog_error.png",
	"data/cog_go.png",
	"data/cog.png",
	"data/cross.png",
	"data/IM_ToolCompile.png",
	"data/IM_ToolDocs.png",
	"data/package.png",
	"data/server.png",
	"data/tick.png",
	"data/plugin.png",
	"data/intro.png",
	"data/fox.ico",
	"data/default.fox",
	"data/default.cfg",
]

APP_NAME = InfoStrings["shortname"]
APP_VERSION = InfoStrings["versionString"]
APP_DESCRIPTION = "Foxtalk Smalltalk Environment"
APP_AUTHOR = "Foxtalkbots.com"
APP_EMAIL = InfoStrings["emailInfo"]
APP_URL = InfoStrings["urlHomepage"]
APP_MAINPY = "foxtalk.py"
APP_COPYRIGHT = InfoStrings["copyright"]
APP_ID = "com.foxtalkbots"
	
# generate default image
#ImageGen().main()

# make win32 distribution
if sys.platform == 'win32':
	import py2exe

	py26MSdll = glob.glob("c:\dev\py26dlls\*.*")

	# py2exe options
	py2exe_options = dict(
		bundle_files = 3,
		compressed = 2, #True,
		optimize = 2
	)

    # main setup
	setup(
		name = APP_NAME,
		version = APP_VERSION,
		description = APP_DESCRIPTION,
		author = APP_AUTHOR,
		url = APP_URL,
		windows = [{
			"script": APP_MAINPY,
			"icon_resources": [(1, "data/fox.ico")],
		}],
		data_files = [("",additionalFiles),
									("Microsoft.VC90.CRT", py26MSdll),
									("lib\Microsoft.VC90.CRT", py26MSdll),
									],
		options = dict(py2exe = py2exe_options),
		zipfile = "lib/library.zip" #None
	)
    
# make OSX distribution
if sys.platform == 'darwin':
	import py2app

	# py2app options
	py2appOptions = dict(
		iconfile = 'data/fox.icns',
		argv_emulation = True,
		compressed = 1,
		optimize = 2,
		plist=dict(
			CFBundleName = APP_NAME,
			CFBundleDisplayName = APP_NAME,
			CFBundleExecutable = APP_NAME,
			CFBundleSignature = APP_NAME,
			CFBundleIdentifier = APP_ID,
			CFBundlePackageType = "APPL",
			CFBundleShortVersionString = APP_VERSION,
			CFBundleVersion = APP_VERSION,
			CFBundleGetInfoString = APP_DESCRIPTION,
			CFBundleIconFile = "fox.icns",
			NSHumanReadableCopyright = APP_COPYRIGHT,
			LSHasLocalizedDisplayName = False,
			NSAppleScriptEnabled = False,
		)
	)

	# main setup
	setup(
		app = [APP_MAINPY],
		name = APP_NAME,
		author = APP_AUTHOR,
		author_email = APP_EMAIL,
		url = APP_URL,
		options = dict(py2app = py2appOptions),
		data_files = additionalFiles,
	)
